Skip to content

Fix ToolStripDropDownMenu scroll boundary handling to prevent out-of-range and unintended dropdown dismissal#14490

Open
LeafShi1 wants to merge 2 commits intodotnet:mainfrom
LeafShi1:Fix_6650_ToolStripScrollDownButton_scroll_issue
Open

Fix ToolStripDropDownMenu scroll boundary handling to prevent out-of-range and unintended dropdown dismissal#14490
LeafShi1 wants to merge 2 commits intodotnet:mainfrom
LeafShi1:Fix_6650_ToolStripScrollDownButton_scroll_issue

Conversation

@LeafShi1
Copy link
Copy Markdown
Member

@LeafShi1 LeafShi1 commented Apr 23, 2026

Fixes #6650

Proposed changes

  • Use explicit visibility checks (fully visible / intersects viewport) instead of edge-based Rectangle.Contains(...).
  • Update scroll button state using item index positions (first/last available item), not pixel min/max.
  • Add an early return in ScrollInternal(bool up) when the target scroll button is already disabled.
  • Treat ToolStripScrollButton as navigation-only (SupportsItemClick = false) so scrolling does not trigger dropdown auto-close behavior.
  • Add regression tests for:
    • down button disabled at end of list,
    • no extra scroll when item is already at boundary,
    • scroll buttons not participating in item-click dismissal.

Customer Impact

  • Fixes scenario where scrolling to the last dropdown item could still allow another down action and hit debug-time failures.
  • Fixes incorrect down-arrow enabled state at bottom boundary.
  • Reduces risk of dropdown collapsing during boundary scroll interaction.
  • Improves reliability and maintainability of scroll behavior for menus with variable item visibility.

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

The ToolStripScrollDownButton is still enabled when displaying the last dropdown item, and in this case, an exception pops up when clicking that ToolStripScrollDownButton again

DropDown_MaximumSize

After

When go through the last dropdown item, the ToolStripScrollDownButton is disabled

AfterChanges.mp4

Test methodology

  • Manually and unit test

Test environment(s)

  • .net 11.0.0-preview.4.26215.121
Microsoft Reviewers: Open in CodeFlow

@LeafShi1 LeafShi1 requested a review from a team as a code owner April 23, 2026 08:40
@LeafShi1 LeafShi1 added the waiting-review This item is waiting on review by one or more members of team label Apr 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes ToolStripDropDownMenu scrolling boundary behavior so scroll buttons reflect actual scrollability, prevent out-of-range scrolling at boundaries, and avoid unintended dropdown dismissal when interacting with scroll buttons.

Changes:

  • Replaces edge-based Rectangle.Contains(...) checks with explicit “fully visible” / “intersects viewport” checks.
  • Updates scroll button enable/disable logic and adds early-return guards to avoid invalid scrolling paths.
  • Marks ToolStripScrollButton as navigation-only (SupportsItemClick = false) and adds regression unit tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripDropDownMenu.cs Adjusts visibility math, scroll boundary logic, and scroll-button status calculation.
src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStripScrollButton.cs Prevents scroll buttons from participating in item-click routing to avoid AutoClose dismissal.
src/test/unit/System.Windows.Forms/ToolStripDropDownMenuTests.cs Adds/updates unit tests covering scroll boundary and scroll-button click behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/test/unit/System.Windows.Forms/ToolStripDropDownMenuTests.cs Outdated
Comment thread src/test/unit/System.Windows.Forms/ToolStripDropDownMenuTests.cs
@SimonZhao888
Copy link
Copy Markdown
Member

Please address the Copilot suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label waiting-review This item is waiting on review by one or more members of team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The ToolStripScrollDownButton should be disabled when displaying and focused on the last dropdown item in order to avoid an exception popping up

3 participants